using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using ComponentFactory.Krypton.Toolkit;
using TinyERP.Framework.Controls;
using TinyERP.Framework;
using Bamboo.Core.Data;
using TinyERP.Framework.Plugin;
using System.Globalization;
using System.Threading;


using System.Xml;
using TinyERP.Framework.Config;
using TinyERP.Core.View.Controls;
using TinyERP.Core.View;
using System.Windows.Forms.RibbonHelpers;
using TinyERP.Core;


namespace TinyERPApp
{
    public partial class MainScreen : KryptonForm
    {
       
        private IDictionary<string, PaletteModeManager> themeDictionary;
        
        private ComponentFactory.Krypton.Toolkit.KryptonManager uiManager;
        private KryptonSplitContainer topSplitter;
        private KRibbonTab dashboardTab;
        private RibbonPanel dashboardPanel;
        private KRibbonButton menuItemMyProfile;
        private KRibbonButton menuItemMyTask;
        private KryptonPanel mainPanel;
        private RibbonPanel languagePanel;
        private RibbonButton viLang;
        private RibbonButton enLanguage;
        private RibbonPanel themePanel;
        private RibbonButton itemOffice2007Black;
        private RibbonButton itemOffice2007Blue;
        private RibbonButton itemOffice2007Silver;
        private RibbonButton itemProfessionalOffice2003;
        private RibbonButton itemProfessionalSystem;
        private RibbonButton itemSparkleBlue;
        private KApplicationRibbon ribbon;
        private KRibbonButton homeMenuItem;
        private KRibbonButton menuItemLogout;
        private KRibbonButton menuItemExit;
        private TabContentPane contentPane;
        
        private System.ComponentModel.IContainer components = null;
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainScreen));
            TinyERP.Framework.Controls.Docking.DockPanelSkin dockPanelSkin2 = new TinyERP.Framework.Controls.Docking.DockPanelSkin();
            TinyERP.Framework.Controls.Docking.AutoHideStripSkin autoHideStripSkin2 = new TinyERP.Framework.Controls.Docking.AutoHideStripSkin();
            TinyERP.Framework.Controls.Docking.DockPanelGradient dockPanelGradient4 = new TinyERP.Framework.Controls.Docking.DockPanelGradient();
            TinyERP.Framework.Controls.Docking.TabGradient tabGradient8 = new TinyERP.Framework.Controls.Docking.TabGradient();
            TinyERP.Framework.Controls.Docking.DockPaneStripSkin dockPaneStripSkin2 = new TinyERP.Framework.Controls.Docking.DockPaneStripSkin();
            TinyERP.Framework.Controls.Docking.DockPaneStripGradient dockPaneStripGradient2 = new TinyERP.Framework.Controls.Docking.DockPaneStripGradient();
            TinyERP.Framework.Controls.Docking.TabGradient tabGradient9 = new TinyERP.Framework.Controls.Docking.TabGradient();
            TinyERP.Framework.Controls.Docking.DockPanelGradient dockPanelGradient5 = new TinyERP.Framework.Controls.Docking.DockPanelGradient();
            TinyERP.Framework.Controls.Docking.TabGradient tabGradient10 = new TinyERP.Framework.Controls.Docking.TabGradient();
            TinyERP.Framework.Controls.Docking.DockPaneStripToolWindowGradient dockPaneStripToolWindowGradient2 = new TinyERP.Framework.Controls.Docking.DockPaneStripToolWindowGradient();
            TinyERP.Framework.Controls.Docking.TabGradient tabGradient11 = new TinyERP.Framework.Controls.Docking.TabGradient();
            TinyERP.Framework.Controls.Docking.TabGradient tabGradient12 = new TinyERP.Framework.Controls.Docking.TabGradient();
            TinyERP.Framework.Controls.Docking.DockPanelGradient dockPanelGradient6 = new TinyERP.Framework.Controls.Docking.DockPanelGradient();
            TinyERP.Framework.Controls.Docking.TabGradient tabGradient13 = new TinyERP.Framework.Controls.Docking.TabGradient();
            TinyERP.Framework.Controls.Docking.TabGradient tabGradient14 = new TinyERP.Framework.Controls.Docking.TabGradient();
            this.dashboardTab = new TinyERP.Framework.Controls.KRibbonTab();
            this.dashboardPanel = new System.Windows.Forms.RibbonPanel();
            this.menuItemMyProfile = new TinyERP.Framework.Controls.KRibbonButton();
            this.menuItemMyTask = new TinyERP.Framework.Controls.KRibbonButton();
            this.languagePanel = new System.Windows.Forms.RibbonPanel();
            this.viLang = new System.Windows.Forms.RibbonButton();
            this.enLanguage = new System.Windows.Forms.RibbonButton();
            this.themePanel = new System.Windows.Forms.RibbonPanel();
            this.itemOffice2007Black = new System.Windows.Forms.RibbonButton();
            this.itemOffice2007Blue = new System.Windows.Forms.RibbonButton();
            this.itemOffice2007Silver = new System.Windows.Forms.RibbonButton();
            this.itemProfessionalOffice2003 = new System.Windows.Forms.RibbonButton();
            this.itemProfessionalSystem = new System.Windows.Forms.RibbonButton();
            this.itemSparkleBlue = new System.Windows.Forms.RibbonButton();
            this.uiManager = new ComponentFactory.Krypton.Toolkit.KryptonManager(this.components);
            this.topSplitter = new ComponentFactory.Krypton.Toolkit.KryptonSplitContainer();
            this.ribbon = new TinyERP.Core.View.Controls.KApplicationRibbon();
            this.homeMenuItem = new TinyERP.Framework.Controls.KRibbonButton();
            this.menuItemLogout = new TinyERP.Framework.Controls.KRibbonButton();
            this.menuItemExit = new TinyERP.Framework.Controls.KRibbonButton();
            this.mainPanel = new ComponentFactory.Krypton.Toolkit.KryptonPanel();
            this.contentPane = new TinyERP.Core.View.Controls.TabContentPane();
            ((System.ComponentModel.ISupportInitialize)(this.topSplitter)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.topSplitter.Panel1)).BeginInit();
            this.topSplitter.Panel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.topSplitter.Panel2)).BeginInit();
            this.topSplitter.Panel2.SuspendLayout();
            this.topSplitter.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.mainPanel)).BeginInit();
            this.mainPanel.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.contentPane)).BeginInit();
            this.SuspendLayout();
            // 
            // dashboardTab
            // 
            this.dashboardTab.Panels.Add(this.dashboardPanel);
            this.dashboardTab.Panels.Add(this.languagePanel);
            this.dashboardTab.Panels.Add(this.themePanel);
            this.dashboardTab.ResourceKey = "Dashboard";
            this.dashboardTab.ResourceModuleKey = "";
            this.dashboardTab.Tag = null;
            this.dashboardTab.Text = "Dashboard";
            // 
            // dashboardPanel
            // 
            this.dashboardPanel.ButtonMoreVisible = false;
            this.dashboardPanel.FlowsTo = System.Windows.Forms.RibbonPanelFlowDirection.Right;
            this.dashboardPanel.Items.Add(this.menuItemMyProfile);
            this.dashboardPanel.Items.Add(this.menuItemMyTask);
            this.dashboardPanel.Tag = null;
            this.dashboardPanel.Text = "Dashboard";
            // 
            // menuItemMyProfile
            // 
            this.menuItemMyProfile.AltKey = null;
            this.menuItemMyProfile.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
            this.menuItemMyProfile.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.menuItemMyProfile.Image = ((System.Drawing.Image)(resources.GetObject("menuItemMyProfile.Image")));
            this.menuItemMyProfile.MaxSizeMode = System.Windows.Forms.RibbonElementSizeMode.Large;
            this.menuItemMyProfile.MinSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.menuItemMyProfile.ResourceKey = "MyProfile";
            this.menuItemMyProfile.ResourceModuleKey = "";
            this.menuItemMyProfile.SmallImage = ((System.Drawing.Image)(resources.GetObject("menuItemMyProfile.SmallImage")));
            this.menuItemMyProfile.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.menuItemMyProfile.Tag = null;
            this.menuItemMyProfile.Text = "My profile";
            this.menuItemMyProfile.ToolTip = null;
            this.menuItemMyProfile.ToolTipImage = null;
            this.menuItemMyProfile.ToolTipTitle = null;
            this.menuItemMyProfile.Click += new System.EventHandler(this.OnEditMyProfile);
            // 
            // menuItemMyTask
            // 
            this.menuItemMyTask.AltKey = null;
            this.menuItemMyTask.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
            this.menuItemMyTask.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.menuItemMyTask.Image = null;
            this.menuItemMyTask.MaxSizeMode = System.Windows.Forms.RibbonElementSizeMode.Large;
            this.menuItemMyTask.MinSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.menuItemMyTask.ResourceKey = "MyTask";
            this.menuItemMyTask.ResourceModuleKey = "";
            this.menuItemMyTask.SmallImage = ((System.Drawing.Image)(resources.GetObject("menuItemMyTask.SmallImage")));
            this.menuItemMyTask.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.menuItemMyTask.Tag = null;
            this.menuItemMyTask.Text = "My tasks";
            this.menuItemMyTask.ToolTip = null;
            this.menuItemMyTask.ToolTipImage = null;
            this.menuItemMyTask.ToolTipTitle = null;
            // 
            // languagePanel
            // 
            this.languagePanel.FlowsTo = System.Windows.Forms.RibbonPanelFlowDirection.Right;
            this.languagePanel.Items.Add(this.viLang);
            this.languagePanel.Items.Add(this.enLanguage);
            this.languagePanel.Tag = null;
            this.languagePanel.Text = "Language";
            // 
            // viLang
            // 
            this.viLang.AltKey = null;
            this.viLang.CheckOnClick = true;
            this.viLang.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
            this.viLang.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.viLang.Image = ((System.Drawing.Image)(resources.GetObject("viLang.Image")));
            this.viLang.MaxSizeMode = System.Windows.Forms.RibbonElementSizeMode.Large;
            this.viLang.SmallImage = ((System.Drawing.Image)(resources.GetObject("viLang.SmallImage")));
            this.viLang.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.viLang.Tag = null;
            this.viLang.Text = "VietNam";
            this.viLang.ToolTip = null;
            this.viLang.ToolTipImage = null;
            this.viLang.ToolTipTitle = null;
            this.viLang.Click += new System.EventHandler(this.OnVNLangClick);
            // 
            // enLanguage
            // 
            this.enLanguage.AltKey = null;
            this.enLanguage.CheckOnClick = true;
            this.enLanguage.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
            this.enLanguage.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.enLanguage.Image = ((System.Drawing.Image)(resources.GetObject("enLanguage.Image")));
            this.enLanguage.MaxSizeMode = System.Windows.Forms.RibbonElementSizeMode.Large;
            this.enLanguage.SmallImage = ((System.Drawing.Image)(resources.GetObject("enLanguage.SmallImage")));
            this.enLanguage.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.enLanguage.Tag = null;
            this.enLanguage.Text = "English";
            this.enLanguage.ToolTip = null;
            this.enLanguage.ToolTipImage = null;
            this.enLanguage.ToolTipTitle = null;
            this.enLanguage.Click += new System.EventHandler(this.OnEnglishClick);
            // 
            // themePanel
            // 
            this.themePanel.ButtonMoreEnabled = false;
            this.themePanel.ButtonMoreVisible = false;
            this.themePanel.Items.Add(this.itemOffice2007Black);
            this.themePanel.Items.Add(this.itemOffice2007Blue);
            this.themePanel.Items.Add(this.itemOffice2007Silver);
            this.themePanel.Items.Add(this.itemProfessionalOffice2003);
            this.themePanel.Items.Add(this.itemProfessionalSystem);
            this.themePanel.Items.Add(this.itemSparkleBlue);
            this.themePanel.Tag = null;
            this.themePanel.Text = "Themes";
            // 
            // itemOffice2007Black
            // 
            this.itemOffice2007Black.AltKey = null;
            this.itemOffice2007Black.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
            this.itemOffice2007Black.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.itemOffice2007Black.Image = global::TinyERPApp.Properties.Resources.iconthemes;
            this.itemOffice2007Black.MaxSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.itemOffice2007Black.MinSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.itemOffice2007Black.SmallImage = global::TinyERPApp.Properties.Resources.iconthemes;
            this.itemOffice2007Black.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.itemOffice2007Black.Tag = null;
            this.itemOffice2007Black.Text = "Office2007Black";
            this.itemOffice2007Black.ToolTip = null;
            this.itemOffice2007Black.ToolTipImage = null;
            this.itemOffice2007Black.ToolTipTitle = null;
            this.itemOffice2007Black.Click += new System.EventHandler(this.OnThemeChange);
            // 
            // itemOffice2007Blue
            // 
            this.itemOffice2007Blue.AltKey = null;
            this.itemOffice2007Blue.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
            this.itemOffice2007Blue.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.itemOffice2007Blue.Image = global::TinyERPApp.Properties.Resources.iconthemes;
            this.itemOffice2007Blue.MaxSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.itemOffice2007Blue.SmallImage = global::TinyERPApp.Properties.Resources.iconthemes;
            this.itemOffice2007Blue.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.itemOffice2007Blue.Tag = null;
            this.itemOffice2007Blue.Text = "Office2007Blue";
            this.itemOffice2007Blue.ToolTip = null;
            this.itemOffice2007Blue.ToolTipImage = null;
            this.itemOffice2007Blue.ToolTipTitle = null;
            this.itemOffice2007Blue.Click += new System.EventHandler(this.OnThemeChange);
            // 
            // itemOffice2007Silver
            // 
            this.itemOffice2007Silver.AltKey = null;
            this.itemOffice2007Silver.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
            this.itemOffice2007Silver.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.itemOffice2007Silver.Image = ((System.Drawing.Image)(resources.GetObject("itemOffice2007Silver.Image")));
            this.itemOffice2007Silver.MaxSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.itemOffice2007Silver.SmallImage = ((System.Drawing.Image)(resources.GetObject("itemOffice2007Silver.SmallImage")));
            this.itemOffice2007Silver.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.itemOffice2007Silver.Tag = null;
            this.itemOffice2007Silver.Text = "Office2007Silver";
            this.itemOffice2007Silver.ToolTip = null;
            this.itemOffice2007Silver.ToolTipImage = null;
            this.itemOffice2007Silver.ToolTipTitle = null;
            this.itemOffice2007Silver.Click += new System.EventHandler(this.OnThemeChange);
            // 
            // itemProfessionalOffice2003
            // 
            this.itemProfessionalOffice2003.AltKey = null;
            this.itemProfessionalOffice2003.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
            this.itemProfessionalOffice2003.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.itemProfessionalOffice2003.Image = ((System.Drawing.Image)(resources.GetObject("itemProfessionalOffice2003.Image")));
            this.itemProfessionalOffice2003.MaxSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.itemProfessionalOffice2003.MinSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.itemProfessionalOffice2003.SmallImage = ((System.Drawing.Image)(resources.GetObject("itemProfessionalOffice2003.SmallImage")));
            this.itemProfessionalOffice2003.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.itemProfessionalOffice2003.Tag = null;
            this.itemProfessionalOffice2003.Text = "ProfessionalOffice2003";
            this.itemProfessionalOffice2003.ToolTip = null;
            this.itemProfessionalOffice2003.ToolTipImage = null;
            this.itemProfessionalOffice2003.ToolTipTitle = null;
            this.itemProfessionalOffice2003.Click += new System.EventHandler(this.OnThemeChange);
            // 
            // itemProfessionalSystem
            // 
            this.itemProfessionalSystem.AltKey = null;
            this.itemProfessionalSystem.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
            this.itemProfessionalSystem.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.itemProfessionalSystem.Image = ((System.Drawing.Image)(resources.GetObject("itemProfessionalSystem.Image")));
            this.itemProfessionalSystem.MaxSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.itemProfessionalSystem.MinSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.itemProfessionalSystem.SmallImage = ((System.Drawing.Image)(resources.GetObject("itemProfessionalSystem.SmallImage")));
            this.itemProfessionalSystem.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.itemProfessionalSystem.Tag = null;
            this.itemProfessionalSystem.Text = "ProfessionalSystem";
            this.itemProfessionalSystem.ToolTip = null;
            this.itemProfessionalSystem.ToolTipImage = null;
            this.itemProfessionalSystem.ToolTipTitle = null;
            this.itemProfessionalSystem.Click += new System.EventHandler(this.OnThemeChange);
            // 
            // itemSparkleBlue
            // 
            this.itemSparkleBlue.AltKey = null;
            this.itemSparkleBlue.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Down;
            this.itemSparkleBlue.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.itemSparkleBlue.Image = ((System.Drawing.Image)(resources.GetObject("itemSparkleBlue.Image")));
            this.itemSparkleBlue.MaxSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.itemSparkleBlue.MinSizeMode = System.Windows.Forms.RibbonElementSizeMode.Medium;
            this.itemSparkleBlue.SmallImage = ((System.Drawing.Image)(resources.GetObject("itemSparkleBlue.SmallImage")));
            this.itemSparkleBlue.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.itemSparkleBlue.Tag = null;
            this.itemSparkleBlue.Text = "SparkleBlue";
            this.itemSparkleBlue.ToolTip = null;
            this.itemSparkleBlue.ToolTipImage = null;
            this.itemSparkleBlue.ToolTipTitle = null;
            this.itemSparkleBlue.Click += new System.EventHandler(this.OnThemeChange);
            // 
            // topSplitter
            // 
            this.topSplitter.ContainerBackStyle = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.PanelClient;
            this.topSplitter.Cursor = System.Windows.Forms.Cursors.Default;
            this.topSplitter.Dock = System.Windows.Forms.DockStyle.Fill;
            this.topSplitter.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
            this.topSplitter.IsSplitterFixed = true;
            this.topSplitter.Location = new System.Drawing.Point(0, 0);
            this.topSplitter.Name = "topSplitter";
            this.topSplitter.Orientation = System.Windows.Forms.Orientation.Horizontal;
            this.topSplitter.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            // 
            // topSplitter.Panel1
            // 
            this.topSplitter.Panel1.Controls.Add(this.ribbon);
            this.topSplitter.Panel1.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.topSplitter.Panel1.PanelBackStyle = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.PanelClient;
            // 
            // topSplitter.Panel2
            // 
            this.topSplitter.Panel2.Controls.Add(this.mainPanel);
            this.topSplitter.Panel2.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.topSplitter.Panel2.PanelBackStyle = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.PanelClient;
            this.topSplitter.SeparatorStyle = ComponentFactory.Krypton.Toolkit.SeparatorStyle.LowProfile;
            this.topSplitter.Size = new System.Drawing.Size(850, 451);
            this.topSplitter.SplitterDistance = 138;
            this.topSplitter.SplitterWidth = 2;
            this.topSplitter.TabIndex = 2;
            // 
            // ribbon
            // 
            this.ribbon.CausesValidation = false;
            this.ribbon.Font = new System.Drawing.Font("Segoe UI", 9F);
            this.ribbon.Location = new System.Drawing.Point(0, 0);
            this.ribbon.Minimized = true;
            this.ribbon.Name = "ribbon";
            // 
            // 
            // 
            this.ribbon.OrbDropDown.BorderRoundness = 8;
            this.ribbon.OrbDropDown.Location = new System.Drawing.Point(0, 0);
            this.ribbon.OrbDropDown.Name = "";
            this.ribbon.OrbDropDown.Size = new System.Drawing.Size(527, 72);
            this.ribbon.OrbDropDown.TabIndex = 0;
            this.ribbon.OrbImage = null;
            this.ribbon.OrbVisible = false;
            // 
            // 
            // 
            this.ribbon.QuickAcessToolbar.AltKey = null;
            this.ribbon.QuickAcessToolbar.Enabled = false;
            this.ribbon.QuickAcessToolbar.Image = null;
            this.ribbon.QuickAcessToolbar.Items.Add(this.homeMenuItem);
            this.ribbon.QuickAcessToolbar.Tag = null;
            this.ribbon.QuickAcessToolbar.Text = null;
            this.ribbon.QuickAcessToolbar.ToolTip = null;
            this.ribbon.QuickAcessToolbar.ToolTipImage = null;
            this.ribbon.QuickAcessToolbar.ToolTipTitle = null;
            this.ribbon.Size = new System.Drawing.Size(850, 138);
            this.ribbon.TabIndex = 0;
            this.ribbon.Tabs.Add(this.dashboardTab);
            this.ribbon.TabSpacing = 6;
            // 
            // homeMenuItem
            // 
            this.homeMenuItem.AltKey = null;
            this.homeMenuItem.CheckOnClick = true;
            this.homeMenuItem.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Up;
            this.homeMenuItem.DropDownArrowSize = new System.Drawing.Size(100, 100);
            this.homeMenuItem.DropDownItems.Add(this.menuItemLogout);
            this.homeMenuItem.DropDownItems.Add(this.menuItemExit);
            this.homeMenuItem.DropDownResizable = true;
            this.homeMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("homeMenuItem.Image")));
            this.homeMenuItem.MaxSizeMode = System.Windows.Forms.RibbonElementSizeMode.Compact;
            this.homeMenuItem.ResourceKey = null;
            this.homeMenuItem.ResourceModuleKey = null;
            this.homeMenuItem.SmallImage = ((System.Drawing.Image)(resources.GetObject("homeMenuItem.SmallImage")));
            this.homeMenuItem.Style = System.Windows.Forms.RibbonButtonStyle.DropDown;
            this.homeMenuItem.Tag = null;
            this.homeMenuItem.Text = "Menu";
            this.homeMenuItem.ToolTip = null;
            this.homeMenuItem.ToolTipImage = null;
            this.homeMenuItem.ToolTipTitle = null;
            // 
            // menuItemLogout
            // 
            this.menuItemLogout.AltKey = null;
            this.menuItemLogout.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Left;
            this.menuItemLogout.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.menuItemLogout.Image = ((System.Drawing.Image)(resources.GetObject("menuItemLogout.Image")));
            this.menuItemLogout.ResourceKey = null;
            this.menuItemLogout.ResourceModuleKey = null;
            this.menuItemLogout.SmallImage = ((System.Drawing.Image)(resources.GetObject("menuItemLogout.SmallImage")));
            this.menuItemLogout.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.menuItemLogout.Tag = null;
            this.menuItemLogout.Text = "Logout";
            this.menuItemLogout.ToolTip = null;
            this.menuItemLogout.ToolTipImage = null;
            this.menuItemLogout.ToolTipTitle = null;
            this.menuItemLogout.Click += new System.EventHandler(this.OnLogout);
            // 
            // menuItemExit
            // 
            this.menuItemExit.AltKey = null;
            this.menuItemExit.DropDownArrowDirection = System.Windows.Forms.RibbonArrowDirection.Left;
            this.menuItemExit.DropDownArrowSize = new System.Drawing.Size(5, 3);
            this.menuItemExit.Image = ((System.Drawing.Image)(resources.GetObject("menuItemExit.Image")));
            this.menuItemExit.ResourceKey = null;
            this.menuItemExit.ResourceModuleKey = null;
            this.menuItemExit.SmallImage = ((System.Drawing.Image)(resources.GetObject("menuItemExit.SmallImage")));
            this.menuItemExit.Style = System.Windows.Forms.RibbonButtonStyle.Normal;
            this.menuItemExit.Tag = null;
            this.menuItemExit.Text = "Exit";
            this.menuItemExit.ToolTip = null;
            this.menuItemExit.ToolTipImage = null;
            this.menuItemExit.ToolTipTitle = null;
            this.menuItemExit.Click += new System.EventHandler(this.OnExitClick);
            // 
            // mainPanel
            // 
            this.mainPanel.Controls.Add(this.contentPane);
            this.mainPanel.Dock = System.Windows.Forms.DockStyle.Fill;
            this.mainPanel.Location = new System.Drawing.Point(0, 0);
            this.mainPanel.Name = "mainPanel";
            this.mainPanel.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.mainPanel.PanelBackStyle = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.PanelAlternate;
            this.mainPanel.Size = new System.Drawing.Size(850, 311);
            this.mainPanel.TabIndex = 5;
            // 
            // contentPane
            // 
            this.contentPane.ActiveAutoHideContent = null;
            this.contentPane.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            this.contentPane.Dock = System.Windows.Forms.DockStyle.Fill;
            this.contentPane.DockBackColor = System.Drawing.SystemColors.Control;
            this.contentPane.DockBottomPortion = 100;
            this.contentPane.DockLeftPortion = 400;
            this.contentPane.DockRightPortion = 200;
            this.contentPane.DockTopPortion = 200;
            this.contentPane.DocumentStyle = TinyERP.Framework.Controls.Docking.DocumentStyle.DockingWindow;
            this.contentPane.Location = new System.Drawing.Point(0, 0);
            this.contentPane.Name = "contentPane";
            this.contentPane.PaletteMode = ComponentFactory.Krypton.Toolkit.PaletteMode.Global;
            this.contentPane.PanelBackStyle = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.PanelClient;
            this.contentPane.Size = new System.Drawing.Size(850, 311);
            dockPanelGradient4.EndColor = System.Drawing.SystemColors.ControlLight;
            dockPanelGradient4.StartColor = System.Drawing.SystemColors.ControlLight;
            autoHideStripSkin2.DockStripGradient = dockPanelGradient4;
            tabGradient8.EndColor = System.Drawing.SystemColors.Control;
            tabGradient8.StartColor = System.Drawing.SystemColors.Control;
            tabGradient8.TextColor = System.Drawing.SystemColors.ControlDarkDark;
            autoHideStripSkin2.TabGradient = tabGradient8;
            dockPanelSkin2.AutoHideStripSkin = autoHideStripSkin2;
            tabGradient9.EndColor = System.Drawing.SystemColors.ControlLightLight;
            tabGradient9.StartColor = System.Drawing.SystemColors.ControlLightLight;
            tabGradient9.TextColor = System.Drawing.SystemColors.ControlText;
            dockPaneStripGradient2.ActiveTabGradient = tabGradient9;
            dockPanelGradient5.EndColor = System.Drawing.SystemColors.Control;
            dockPanelGradient5.StartColor = System.Drawing.SystemColors.Control;
            dockPaneStripGradient2.DockStripGradient = dockPanelGradient5;
            tabGradient10.EndColor = System.Drawing.SystemColors.ControlLight;
            tabGradient10.StartColor = System.Drawing.SystemColors.ControlLight;
            tabGradient10.TextColor = System.Drawing.SystemColors.ControlText;
            dockPaneStripGradient2.InactiveTabGradient = tabGradient10;
            dockPaneStripSkin2.DocumentGradient = dockPaneStripGradient2;
            tabGradient11.EndColor = System.Drawing.SystemColors.ActiveCaption;
            tabGradient11.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
            tabGradient11.StartColor = System.Drawing.SystemColors.GradientActiveCaption;
            tabGradient11.TextColor = System.Drawing.SystemColors.ActiveCaptionText;
            dockPaneStripToolWindowGradient2.ActiveCaptionGradient = tabGradient11;
            tabGradient12.EndColor = System.Drawing.SystemColors.Control;
            tabGradient12.StartColor = System.Drawing.SystemColors.Control;
            tabGradient12.TextColor = System.Drawing.SystemColors.ControlText;
            dockPaneStripToolWindowGradient2.ActiveTabGradient = tabGradient12;
            dockPanelGradient6.EndColor = System.Drawing.SystemColors.ControlLight;
            dockPanelGradient6.StartColor = System.Drawing.SystemColors.ControlLight;
            dockPaneStripToolWindowGradient2.DockStripGradient = dockPanelGradient6;
            tabGradient13.EndColor = System.Drawing.SystemColors.GradientInactiveCaption;
            tabGradient13.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
            tabGradient13.StartColor = System.Drawing.SystemColors.GradientInactiveCaption;
            tabGradient13.TextColor = System.Drawing.SystemColors.ControlText;
            dockPaneStripToolWindowGradient2.InactiveCaptionGradient = tabGradient13;
            tabGradient14.EndColor = System.Drawing.Color.Transparent;
            tabGradient14.StartColor = System.Drawing.Color.Transparent;
            tabGradient14.TextColor = System.Drawing.SystemColors.ControlDarkDark;
            dockPaneStripToolWindowGradient2.InactiveTabGradient = tabGradient14;
            dockPaneStripSkin2.ToolWindowGradient = dockPaneStripToolWindowGradient2;
            dockPanelSkin2.DockPaneStripSkin = dockPaneStripSkin2;
            this.contentPane.Skin = dockPanelSkin2;
            this.contentPane.TabIndex = 0;
            // 
            // MainScreen
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(850, 451);
            this.Controls.Add(this.topSplitter);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.IsMdiContainer = true;
            this.Name = "MainScreen";
            this.Text = "TinyERP";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            ((System.ComponentModel.ISupportInitialize)(this.topSplitter.Panel1)).EndInit();
            this.topSplitter.Panel1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.topSplitter.Panel2)).EndInit();
            this.topSplitter.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.topSplitter)).EndInit();
            this.topSplitter.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.mainPanel)).EndInit();
            this.mainPanel.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.contentPane)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        
       
      
   
       
        public MainScreen()
        {
            InitializeComponent();
            ApplicationLoader.Run();
        }
        protected override void OnLoad(EventArgs e)
        {
            this.IsMdiContainer = true;
            UIManager.GetInstance().ApplyCurrentCultureInfo(this);
            if (Login())
            {
                LoadDefaultTheme();
                InitNavigationPanel();
                InitMainPanel();
                WireGlobalKeyEvents();
                UIManager.MainScreen = this;
                
            }
            else
            {
                Application.Exit();
            }
        }
        private bool Login()
        {
            LoginForm loginForm = new LoginForm();
            DialogResult dialogResult = loginForm.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                return true;
            }
            return false;
        }
       

        

        private void OnChangeTheme(string themeKey)
        {
            ApplicationConfiguration.GetInstance().DefaultTheme = themeKey;
            PaletteModeManager theme = themeDictionary[ApplicationConfiguration.GetInstance().DefaultTheme];
            uiManager.ResetGlobalPaletteMode();
            uiManager.ResetGlobalPalette();
            uiManager.ResetGlobalAllowFormChrome();
            uiManager.GlobalPaletteMode = theme;
        }

        private void LoadDefaultTheme()
        {
            BuildThemeDictionary();
            uiManager.GlobalAllowFormChrome = true;
            uiManager.GlobalApplyToolstrips = true;
            PaletteModeManager theme = themeDictionary[ApplicationConfiguration.GetInstance().DefaultTheme];
            uiManager.GlobalPaletteMode = theme;
        }

        private void BuildThemeDictionary()
        {
            themeDictionary = new Dictionary<string, PaletteModeManager>();
            themeDictionary.Add("Office2007Black", PaletteModeManager.Office2007Black);
            themeDictionary.Add("Office2007Blue", PaletteModeManager.Office2007Blue);
            themeDictionary.Add("Office2007Silver", PaletteModeManager.Office2007Silver);
            themeDictionary.Add("ProfessionalOffice2003", PaletteModeManager.ProfessionalOffice2003);
            themeDictionary.Add("ProfessionalSystem", PaletteModeManager.ProfessionalSystem);
            themeDictionary.Add("SparkleBlue", PaletteModeManager.SparkleBlue);
            themeDictionary.Add("SparkleOrange", PaletteModeManager.SparkleOrange);
            themeDictionary.Add("SparklePurple", PaletteModeManager.SparklePurple);
        }

        
        private void WireGlobalKeyEvents()
        {
            this.KeyPreview = true;
            this.KeyDown += delegate(object sender, KeyEventArgs e)
            {
                ShortcutHandler.GetInstance().HandleEvent(e);
            };
        }

        
        protected void InitNavigationPanel()
        {
            UIManager.GetInstance().ApplicationRibbon = this.ribbon;
            UIManager.GetInstance().ReloadNavigator();

        }


        protected void InitMainPanel()
        {
           UIManager.GetInstance().ContentPanel = this.contentPane;
            
        }

        #region HelpMenuItemHandler Members

        public void ShowAboutDialog()
        {
            About aboutForm = new About();
            aboutForm.ShowDialog(this);
        }

        #endregion

        private void OnExitClick(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void OnLogout(object sender, EventArgs e)
        {
            Session.Logout();
        }

        private void OnVNLangClick(object sender, EventArgs e)
        {
            UIManager.GetInstance().ContentPanel.CloseAllPanes();
            UIManager.GetInstance().ChangeLanguage("vi-VN", this.FindForm());
        }

        private void OnEnglishClick(object sender, EventArgs e)
        {
            UIManager.GetInstance().ContentPanel.CloseAllPanes();
            UIManager.GetInstance().ChangeLanguage("en-US", this.FindForm());
        }

        private void OnThemeChange(object sender, EventArgs e)
        {
            string themeKey = ((RibbonButton)sender).Text;
            ApplicationConfiguration.GetInstance().DefaultTheme = themeKey;
            PaletteModeManager theme = themeDictionary[ApplicationConfiguration.GetInstance().DefaultTheme];
            uiManager.ResetGlobalPaletteMode();
            uiManager.ResetGlobalPalette();
            uiManager.ResetGlobalAllowFormChrome();
            uiManager.GlobalPaletteMode = theme;
        }

        private void OnEditMyProfile(object sender, EventArgs e)
        {
            UserEditInfoForm editUserForm = new UserEditInfoForm();
            editUserForm.User = Session.LoginUser;
            editUserForm.IsEditMode = true;
            editUserForm.ApplyACL(true, false, false);
            new DialogHelper(editUserForm).ShowDialog(UIManager.MainScreen);
        }
    }
}
